<?php
/**
 * @package		Joomla.Administrator
 * @subpackage	com_congregation
 * @copyright	Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

// no direct access
defined('_JEXEC') or die;

JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');
?>
<script type="text/javascript">
	Joomla.submitbutton = function(task)
	{
		if (task == 'profile.cancel' || document.formvalidator.isValid(document.id('profile-form'))) {
			Joomla.submitform(task, document.getElementById('profile-form'));
		}
		else {
			alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>');
		}
	}
</script>

<?php defined('_JEXEC') or die('Restricted access'); ?>
<form action="<?php echo JRoute::_('index.php?option=com_congregation&view=profile&layout=edit&id='.(int) $this->item->id); ?>" method="post" name="adminForm"  id="profile-form" class="form-validate">

	<div class="width-60 fltlft">
		<fieldset class="adminform">
			<legend><?php echo JText::_('Details') ?></legend>
			<ul class="adminformlist">
				<li><?php echo $this->form->getLabel('uid'); ?>
				<?php echo $this->form->getInput('uid'); ?></li>

				<li><?php echo $this->form->getLabel('status'); ?>
				<?php echo $this->form->getInput('status'); ?></li>
				
				
				<li><?php echo $this->form->getLabel('bdate'); ?>
				<?php echo $this->form->getInput('bdate'); ?></li>

				<li><?php echo $this->form->getLabel('eplace'); ?>
				<?php echo $this->form->getInput('eplace'); ?></li>

				<li><?php echo $this->form->getLabel('ndate'); ?>
				<?php echo $this->form->getInput('ndate'); ?></li>

				<li><?php echo $this->form->getLabel('vplace'); ?>
				<?php echo $this->form->getInput('vplace'); ?></li>

				<li><?php echo $this->form->getLabel('fdate'); ?>
				<?php echo $this->form->getInput('fdate'); ?></li>

				<li><?php echo $this->form->getLabel('oplace'); ?>
				<?php echo $this->form->getInput('oplace'); ?></li>

				<li><?php echo $this->form->getLabel('ddate'); ?>
				<?php echo $this->form->getInput('ddate'); ?></li>


				<li><?php echo $this->form->getLabel('altemail'); ?>
				<?php echo $this->form->getInput('altemail'); ?></li>

				<li><?php echo $this->form->getLabel('cell'); ?>
				<?php echo $this->form->getInput('cell'); ?></li>

				<li><?php echo $this->form->getLabel('skype'); ?>
				<?php echo $this->form->getInput('skype'); ?></li>

				<li><?php echo $this->form->getLabel('language'); ?>
				<?php echo $this->form->getInput('language'); ?></li>

				<li><?php echo $this->form->getLabel('nationality'); ?>
				<?php echo $this->form->getInput('nationality'); ?></li>

				<li><?php echo $this->form->getLabel('ordering'); ?>
				<?php echo $this->form->getInput('ordering'); ?></li>


			</ul>
		</fieldset>
	</div>

	<div class="width-40 fltrt">
		<fieldset class="adminform">
			<legend><?php echo JText::_('Photos') ?></legend>
				<?php echo $this->form->getLabel('picfile'); ?>
				<div class="clr"></div>
				<?php echo $this->form->getInput('picfile'); ?>
			</div>
			
		</fieldset>
	</div>
	<div class="clr"></div>
	
	<div class="width-100 fltlft">
		<fieldset class="adminform">
			<legend><?php echo JText::_('Paths') ?></legend>
	
	<?php $house_list_option = '' ; //to get ?>
	<?php $last_p_id = 0 ?>
	<?php foreach($this->houses as $house): ?>
	<?php if($last_p_id != $house->p_id): ?>
	<?php $house_list_option .= "<option disabled=\"disabled\">" . $house->p_name . "</option>"; ?>
	<?php endif; ?>
	<?php $last_p_id = $house->p_id ?>
	<?php $house_list_option .= "<option value=\"" . $house->c_id . "\" >|__ " . $house->c_name . "</option>"; ?>
	<?php endforeach; ?>
	
	<?php 
	$day_list = "<option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option><option>10</option><option>11</option><option>12</option><option>13</option><option>14</option><option>15</option><option>16</option><option>17</option><option>18</option><option>19</option><option>20</option><option>21</option><option>22</option><option>23</option><option>24</option><option>24</option><option>25</option><option>26</option><option>27</option><option>28</option><option>29</option><option>30</option><option>31</option>";
	$month_list = "<option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option><option>10</option><option>11</option><option>12</option>";
	$year_list = "";
	$thisyear = date("Y");

	for ($j = $thisyear; $j >= $thisyear - 100 ; $j--) {
		$year_list .= "<option value='$j'>$j</option>\n";
	}
	?>	
<table width="100%" class="admintable">
<thead>
	<tr>
		<th class="key"><?php echo JText::_('Date') ?></th>
		<th><?php echo JText::_('Community') ?></th>
		<th><?php echo JText::_('Event or Responsibility') ?></th>
		<th><?php echo Jtext::_('Current') ?></th>
		<th><?php echo Jtext::_('Delete') ?></th>
	</tr>
</thead>
<tbody>
	<?php $i = 0 ; ?>
	<?php if(!empty($this->item->paths)): ?>
	
	<?php foreach($this->item->paths as $path) : ?>
	<tr>
		<td>
		<select name="path[<?php echo $i ?>][t_day]">
		<option><?php echo substr($path->t_date,8,2) ?></option>
		<?php echo $day_list ?>
		</select>
		<select name="path[<?php echo $i ?>][t_month]">
		<option><?php echo substr($path->t_date,5,2) ?></option>
		<?php echo $month_list ?>
		</select>
		<select name="path[<?php echo $i ?>][t_year]">
		<option><?php echo substr($path->t_date,0,4) ?></option>
		<?php echo $year_list ?>
		</select>
		</td>
		<td>
		<select name="path[<?php echo $i ?>][t_house]">
		<option value="<?php echo $path->t_cid ?>"><?php echo $path->c_name ?></option>
		<?php echo $house_list_option ?>
		</select>
		</td>
		<td>
		<input type='text' name="path[<?php echo $i ?>][t_charge]" value="<?php echo $path->t_charge ?>" />
		</td>
		<td>
		<input type='radio' name="t_current" value="<?php echo $i ?>" <?php if($path->t_current == 1) echo " checked='checked' " ?> />
		</td>
		<td>
		<input type='checkbox' name="path[<?php echo $i ?>][delete]" value="1" />
		</td>
	</tr>
	<?php $i++; endforeach; ?>
	<?php endif; ?>
	<?php for($j = $i; $j < $i + 5; $j++): ?>
	<tr>
		<td>
		<select name="path[<?php echo $j ?>][t_day]">
		<option></option>
		<?php echo $day_list ?>
		</select>
		<select name="path[<?php echo $j ?>][t_month]">
		<option></option>
		<?php echo $month_list ?>
		</select>
		<select name="path[<?php echo $j ?>][t_year]">
		<option></option>
		<?php echo $year_list ?>
		</select>
		
		</td>
		<td>
		<select name="path[<?php echo $j ?>][t_house]">
		<option></option>
		<?php echo $house_list_option ?>
		</select>
		</td>
		<td>
		<input type='text'  name="path[<?php echo $j ?>][t_charge]" value="" />
		</td>
		<td>
		<input type='radio' name="t_current" value="<?php echo $j ?>" />
		</td>
	</tr>
	
	<?php endfor; ?>
</tbody>
</table>	
	</fieldset>
	</div>
	
	
	
	

		<input type="hidden" name="task" value="" />
		<?php echo JHtml::_('form.token'); ?>
</form>

